package org.eerbaar.parser.core.def.impl;

import java.util.List;

import org.eerbaar.parser.core.def.NonTerminal;
import org.eerbaar.parser.core.def.Production;
import org.eerbaar.parser.core.def.Symbol;

public abstract class DefaultProduction
    implements Production {

    protected NonTerminal lhs;
    protected List<Symbol> rhs;

    @Override
    public NonTerminal getLHS() {
        return lhs;
    }

    @Override
    public Symbol[] getRHS() {
        return rhs.toArray(new Symbol[] {});
    }

    @Override
    public String toString() {
        String s = lhs + " ->";
        for (int i = 0; i < rhs.size(); i++) {
            s += " " + rhs.get(i).getName();
        }
        return s;
    }
}
